"""资源相关数据模型"""

from pydantic import BaseModel, Field
from typing import List, Optional
from datetime import datetime

class ECSInstance(BaseModel):
    """云服务器实例模型"""
    id: str = Field(..., description="实例ID")
    name: Optional[str] = Field(None, description="实例名称")
    instance_type: Optional[str] = Field(None, description="实例类型")
    status: Optional[str] = Field(None, description="实例状态")
    public_ip: Optional[str] = Field(None, description="公网IP")
    private_ip: Optional[str] = Field(None, description="私网IP")
    region: Optional[str] = Field(None, description="所属区域")
    zone: Optional[str] = Field(None, description="可用区")
    created_at: Optional[datetime] = Field(None, description="创建时间")

class OSSBucket(BaseModel):
    """对象存储桶模型"""
    name: str = Field(..., description="存储桶名称")
    region: Optional[str] = Field(None, description="所属区域")
    storage_class: Optional[str] = Field("Standard", description="存储类型")
    created_at: Optional[datetime] = Field(None, description="创建时间")
    size: Optional[int] = Field(0, description="存储大小(字节)")

class RDSInstance(BaseModel):
    """数据库实例模型"""
    id: str = Field(..., description="实例ID")
    name: Optional[str] = Field(None, description="实例名称")
    engine: Optional[str] = Field(None, description="数据库引擎")
    engine_version: Optional[str] = Field(None, description="引擎版本")
    status: Optional[str] = Field(None, description="实例状态")
    region: Optional[str] = Field(None, description="所属区域")
    created_at: Optional[datetime] = Field(None, description="创建时间")

class SLBInstance(BaseModel):
    """负载均衡实例模型"""
    id: str = Field(..., description="实例ID")
    name: Optional[str] = Field(None, description="实例名称")
    status: Optional[str] = Field(None, description="实例状态")
    type: Optional[str] = Field(None, description="负载均衡类型")
    region: Optional[str] = Field(None, description="所属区域")
    address: Optional[str] = Field(None, description="服务地址")

class ResourceList(BaseModel):
    """资源列表响应模型"""
    ecs: List[ECSInstance] = Field(default_factory=list, description="云服务器列表")
    oss: List[OSSBucket] = Field(default_factory=list, description="对象存储列表")
    rds: List[RDSInstance] = Field(default_factory=list, description="数据库列表")
    slb: List[SLBInstance] = Field(default_factory=list, description="负载均衡列表")

class ResourceQuery(BaseModel):
    """资源查询参数模型"""
    region: Optional[str] = Field(None, description="区域筛选")
    type: Optional[str] = Field(None, description="资源类型筛选")
